package com.xiangxiangjd.kj.papersstar.controller;

import com.xiangxiangjd.kj.papersstar.bean.UserAnswer;
import com.xiangxiangjd.kj.papersstar.bean.result.ResultPage;
import com.xiangxiangjd.kj.papersstar.controller.model.ApiResultModel;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 肖守凯
 * @since 2021-01-26
 */
@Controller
@RequestMapping("/papersstar/userAnswer")
public class UserAnswerController extends BaseController{



     /** 主页面 */
    @RequestMapping("admin/main.html")
    public String main(){
       return  "UserAnswer/UserAnswerMain";
    }
    /** 添加页面跳转
     * @return 返回页面
     */
    @RequestMapping(value = "admin/addUserAnswerHtml")
    public String addUserAnswerHtml( ){
             return "UserAnswer/UserAnswerAdd";
    }
    /** 编辑页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "admin/editUserAnswerHtml")
    public String editUserAnswerHtml(String id ,Model model ){
           model.addAttribute("userAnswer",userAnswerService.selectUserAnswerByIdUserAnswer(id));
             return "UserAnswer/UserAnswerEdit";
    }

    /** 查看页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "admin/showUserAnswerHtml")
    public String showUserAnswerHtml(String id ,Model model ){
           model.addAttribute("userAnswer",userAnswerService.selectUserAnswerByIdUserAnswer(id));
             return "UserAnswer/UserAnswerShow";
    }


    /** 分页查询UserAnswer
     * @param page  页码
     * @param limit  查几条
     * @param userAnswer  前端传进的参数
     * @return 返回统一分页信息
     */
    @RequestMapping(value = "admin/findUserAnswerByPage")
    @ResponseBody
    public ResultPage findUserAnswerByPage(Integer page, Integer limit,UserAnswer userAnswer){
             return userAnswerService.findUserAnswerByPage(page,limit,userAnswer);
    }

    /** 添加UserAnswer
     * @param userAnswer  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/addUserAnswer")
    @ResponseBody
    public ApiResultModel saveUserAnswer(UserAnswer userAnswer  ){
             return userAnswerService.addUserAnswer(userAnswer);
    }

    /** 编辑UserAnswer
     * @param userAnswer  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/editUserAnswer")
    @ResponseBody
    public ApiResultModel editUserAnswer(UserAnswer userAnswer  ){
             return userAnswerService.editUserAnswer(userAnswer);
    }



    /** 删除UserAnswer
     * @param ids  前端传进的ID
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/delUserAnswer",method = RequestMethod.GET)
    @ResponseBody
    public ApiResultModel delUserAnswer(@RequestParam("datas[]") ArrayList ids){


             return userAnswerService.delUserAnswers(ids);
    }


}
